package com.xiaoke.security.verificationCode;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;

/**
 * @Author 小柯
 * @Date 2019/11/3  15:43
 * 图片验证码
 **/

public class ImageCode {

    //图片
    private BufferedImage image;

    //条码
    private String code;

    //到期时间
    private LocalDateTime expireTime;

    public ImageCode(BufferedImage image, String code, int expireTime){
        this.image = image;
        this.code = code;
        //当前时间 加上 过期时间
        this.expireTime = LocalDateTime.now().plusSeconds(expireTime);

    }
    public boolean isExpried() {
        return LocalDateTime.now().isAfter(expireTime);
    }
    public BufferedImage getImage() {
        return image;
    }

    public void setImage(BufferedImage image) {
        this.image = image;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }
}
